<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="GridView.aspx.cs" Inherits="www.Update_GridView" Title="Untitled Page" %>

<%@ Register Assembly="NBusiness" Namespace="NBusiness.Data.Web" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="BeerId"
        DataSourceID="BeerCollectionDS" OnRowDataBound="GridView1_RowDataBound" Width="100%" OnRowUpdating="GridView1_RowUpdating">
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="UpdateBtn" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit"></asp:LinkButton>
                    <%--<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Delete" Visible='<%# IsDeleteBtnVisible( (int) Eval("Item_Id")) %>'></asp:LinkButton>--%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="AvailabilityId" SortExpression="AvailabilityId">
                <ItemTemplate>
                    <asp:HyperLink ID="AvailabilityLink" runat="server" NavigateUrl='<%# Eval("AvailabilityId", "~/Search/ByAvailability.aspx?a={0}") %>'></asp:HyperLink>
                </ItemTemplate>                
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AvailabilityCollectionDS"
                        DataTextField="Text" DataValueField="AvailabilityId" SelectedValue='<%# Bind("AvailabilityId") %>'>
                    </asp:DropDownList>                    
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="BeerId" HeaderText="BeerId" InsertVisible="False" ReadOnly="True"
                SortExpression="BeerId" />
            <asp:TemplateField HeaderText="Alcohol" SortExpression="Alcohol">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Alcohol") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Width="50" Text='<%# Bind("Alcohol") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="BeerStyleId" SortExpression="BeerStyleId">
                <ItemTemplate>
                    <asp:HyperLink ID="StyleLink" runat="server" NavigateUrl='<%# Eval("BeerStyleId", "~/Search/ByStyle.aspx?s={0}") %>'></asp:HyperLink>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="BeerStyleCollectionDS"
                        DataTextField="Name" DataValueField="BeerStyleId" SelectedValue='<%# Bind("BeerStyleId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="CompanyId" SortExpression="CompanyId">
                <ItemTemplate>
                    <asp:HyperLink ID="CompanyLink" runat="server" NavigateUrl='<%# Eval("CompanyId", "~/Company.aspx?c={0}") %>'></asp:HyperLink>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="CompanyCollectionDS"
                        DataTextField="Name" DataValueField="CompanyId" SelectedValue='<%# Bind("CompanyId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <!-- Data Source -->
    <cc1:EntityDataSource ID="BeerCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.BeerCollection" OnSelect="BeerDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="AvailabilityCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CachedAvailabilityCollection" OnSelect="AvailDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="BeerStyleCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CachedBeerStyleCollection" OnSelect="BeerStyleDataSource_Select">
    </cc1:EntityDataSource>
    <cc1:EntityDataSource ID="CompanyCollectionDS" runat="server" AssemblyName="Example.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        TypeName="BeerBase.Business.CompanyCollection" OnSelect="CompanyDataSource_Select">
    </cc1:EntityDataSource>
</asp:Content>

